home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / math / alged34.zip / ALGEDSRC.ZIP / MOUSE.C < prev    next >
C/C++ Source or Header  |  1996-06-06  |  1KB  |  61 lines

  1. /*--------------------------------------------------------------------
  2.    this is the code for DOS (Turbo C++)
  3. */
  4. #define MOUSEINT 0x33
  5. #include <dos.h>
  6.  
  7. /*
  8.    To do various functions (input) [output] set 'a' to
  9.     0 - test if loaded [reg.ax = $ffff]
  10.     1 - show cursor
  11.     2 - hide cursor
  12.     3 - get position [b buttons, c x, d y]
  13.     4 - set position (c x,d y)
  14.     5 - press button   (b buttons, c x, d y) [b count]
  15.     6 - release button (b buttons, c x, d y) [b count]
  16.     7 - set x range  (c min, d max)
  17.     8 - set y range  (c min, d max)
  18.     10- text cursor  (b 0=soft 1=hard, c ?, d ?)
  19.     15- mickeys      (c xscale, d yscale?)
  20. */
  21. int mouse(int a,int *b,int *c,int *d)
  22. {
  23.   static union REGS regs;
  24.   regs.x.ax = a;
  25.   regs.x.bx = *b;
  26.   regs.x.cx = *c;
  27.   regs.x.dx = *d;
  28.   int86(MOUSEINT,®s,®s);
  29.   *b = regs.x.bx;
  30.   *c = regs.x.cx;
  31.   *d = regs.x.dx;
  32.   return regs.x.ax;
  33. }
  34.  
  35. int init_mouse(void) {
  36.   int x=0;
  37.   long *p;
  38.   /*  this is some code to try to avoid hangs when int 33 is not
  39.       loaded with anything. */
  40.   p = (long*)(MOUSEINT * 4);
  41.   if (*p==0) return 1;
  42.   return mouse(0,&x,&x,&x);
  43. }
  44.  
  45. int show_mouse(void) {
  46.   int b=0; return mouse(1,&b,&b,&b);
  47. }
  48.  
  49. int hide_mouse(void) {
  50.   int b=0; return mouse(2,&b,&b,&b);
  51. }
  52.  
  53. int get_mouse(int *x,int *y) {
  54.   int b=0; mouse(3,&b,x,y); return b;
  55. }
  56.  
  57. int set_mouse(int x,int y) {
  58.   int b=0; return mouse(4,&b,&x,&y);
  59. }
  60.  
  61.